﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //判断是否存在mySolo
            bool File = Directory.Exists("D:\\mySolo");
            if(File)
            {
                //删除mySolo
                Directory.Delete("D:\\mySolo",true);
            }
            else
            {
                //新建mySolo
                Directory.CreateDirectory("D:\\mySolo");
                //新建txt文件
                FileInfo fileInfo = new FileInfo("D:\\mySolo\\text.txt");
                //判断是否有同名文件
                if(!fileInfo.Exists)
                {
                    //创建文件
                    fileInfo.Create().Close();
                    //插入内容
                    string path = @"D:\\mySolo\\text.txt";
                    StreamWriter streamWriter = new StreamWriter(path);
                    streamWriter.Write("花有重开日,人无再少年");
                    //刷新缓存
                    streamWriter.Flush();
                    //关闭流
                    streamWriter.Close();
                }
            }
        }
    }
}
